<template>
  <div v-if="type === 'bpmn:MessageEventDefinition'">
    <c-form :inline="true" :form="form" ref="refForm"></c-form>
  </div>
</template>

<script>
import Form from "@/components/Form.vue";
import {MessageIntermediateCatchEventForm} from "@/components/bpmn/components/bpmnPropertiesPanel/forms";
import {getTimerDefinitionType} from "@/bpmn/util/common";

export default {
  name: "Properties_MessageIntermediateCatchEvent",
  components: {
    "c-form": Form
  },
  computed:{
    type() {
      if(this?.bpmnElement?.businessObject?.eventDefinitions){
        return this.bpmnElement.businessObject.eventDefinitions[0].$type;
      }
      return null;
    }
  },
  data() {
    return {
      bpmnElement: null,
      form: MessageIntermediateCatchEventForm.call(this)
    }
  },

  methods: {
    // 数据回填
    dataReset() {
      const modeler = this.modeler;
      let eventDefinitions = modeler.getProperty("eventDefinitions")
      if(eventDefinitions){
        eventDefinitions = eventDefinitions[0];
        const type = getTimerDefinitionType(eventDefinitions);
        const definition = eventDefinitions.get(type);
        if(definition){
          const body = definition.get('body');
          this.form.models.type = type;
          this.form.models.content = body;
        }
      }
    }
  },
}
</script>

<style scoped>

</style>